Skip to contentSkip to conversation

Change in openvpn[master]: Avoid possible race condition that kill OpenVPN itself

Openvpn-devel In review plaisthos (Code Review) 2 participants 6 messages Oct 27, 2025 – Oct 28, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1761599429000.I7b94de92723f9528b01cb932bb079eedf0f1f272@...2715...

#1 lore raw

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1319?usp=email

to review the following change.

Change subject: Avoid possible race condition that kill OpenVPN itself
......................................................................

Avoid possible race condition that kill OpenVPN itself

If for whatever reason the child pid is zero, we would kill ourselves since killing 0 means killing the own process group.

Found-By Zeropath
Change-Id I7b94de92723f9528b01cb932bb079eedf0f1f272

---
M src/openvpn/tun_afunix.c

1 file changed, 6 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/19/1319/1

src/openvpn/tun_afunix.c +6 -1
index 4d48a31..124db6d 100644
@@ -128,7 +128,12 @@
         close(tt->fd);
         tt->fd = 0;
     }
-    kill(tt->afunix.childprocess, SIGINT);
+    /* only kill the child process if the PID is not 0 to avoid killing
+     * ourselves by accident */
+    if (tt->afunix.childprocess)
+    {
+        kill(tt->afunix.childprocess, SIGINT);
+    }
 
     free(tt->actual_name);
     free(tt);

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1319?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7b94de92723f9528b01cb932bb079eedf0f1f272
Gerrit-Change-Number: 1319
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1319?usp=email )

Change subject: Avoid possible race condition that kill OpenVPN itself
......................................................................

Patch Set 1: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1319?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7b94de92723f9528b01cb932bb079eedf0f1f272
Gerrit-Change-Number: 1319
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 27 Oct 2025 21:32:54 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH 1/1 Avoid possible race condition that kill OpenVPN itself

In reply to a message not in the archive

From: Arne Schwabe <[email protected]...>

If for whatever reason the child pid is zero, we would kill ourselves since killing 0 means killing the own process group.

Found-By Zeropath
Change-Id I7b94de92723f9528b01cb932bb079eedf0f1f272

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1319
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1319
This mail reflects revision 1 of this Change.

Signed-off-by line for the author was added as per our policy.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/tun_afunix.c +6 -1
index 4d48a31..124db6d 100644
@@ -128,7 +128,12 @@
         close(tt->fd);
         tt->fd = 0;
     }
-    kill(tt->afunix.childprocess, SIGINT);
+    /* only kill the child process if the PID is not 0 to avoid killing
+     * ourselves by accident */
+    if (tt->afunix.childprocess)
+    {
+        kill(tt->afunix.childprocess, SIGINT);
+    }
 
     free(tt->actual_name);
     free(tt);
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Avoid possible race condition that kill OpenVPN itself

Amazing find by ZeroPath, and trivially correct fix.

I have completed Joshua's "reported-by:" line (full name) in the commit message.

Your patch has been applied to the master branch.

commit 18309ff64833523c1ad19e7d56d6f756b53966af

Author: Arne Schwabe
Date:   Mon Oct 27 22:33:02 2025 +0100
     Avoid possible race condition that kill OpenVPN itself

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1319
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg33910.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#2) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1319?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: Avoid possible race condition that kill OpenVPN itself
......................................................................

Avoid possible race condition that kill OpenVPN itself

If for whatever reason the child pid is zero, we would kill ourselves since killing 0 means killing the own process group.

Found-By Zeropath
Change-Id I7b94de92723f9528b01cb932bb079eedf0f1f272

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1319
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33910.html

---
M src/openvpn/tun_afunix.c

1 file changed, 6 insertions(+), 1 deletion(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/19/1319/2

src/openvpn/tun_afunix.c +6 -1
index 4d48a31..124db6d 100644
@@ -128,7 +128,12 @@
         close(tt->fd);
         tt->fd = 0;
     }
-    kill(tt->afunix.childprocess, SIGINT);
+    /* only kill the child process if the PID is not 0 to avoid killing
+     * ourselves by accident */
+    if (tt->afunix.childprocess)
+    {
+        kill(tt->afunix.childprocess, SIGINT);
+    }
 
     free(tt->actual_name);
     free(tt);

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1319?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7b94de92723f9528b01cb932bb079eedf0f1f272
Gerrit-Change-Number: 1319
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1319?usp=email )

Change subject: Avoid possible race condition that kill OpenVPN itself
......................................................................

Avoid possible race condition that kill OpenVPN itself

If for whatever reason the child pid is zero, we would kill ourselves since killing 0 means killing the own process group.

Found-By Zeropath
Change-Id I7b94de92723f9528b01cb932bb079eedf0f1f272

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1319
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg33910.html

---
M src/openvpn/tun_afunix.c

1 file changed, 6 insertions(+), 1 deletion(-)
src/openvpn/tun_afunix.c +6 -1
index 4d48a31..124db6d 100644
@@ -128,7 +128,12 @@
         close(tt->fd);
         tt->fd = 0;
     }
-    kill(tt->afunix.childprocess, SIGINT);
+    /* only kill the child process if the PID is not 0 to avoid killing
+     * ourselves by accident */
+    if (tt->afunix.childprocess)
+    {
+        kill(tt->afunix.childprocess, SIGINT);
+    }
 
     free(tt->actual_name);
     free(tt);

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1319?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I7b94de92723f9528b01cb932bb079eedf0f1f272
Gerrit-Change-Number: 1319
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>